import * as axios from "axios"
const Axios:any=axios
const HttpAxios:axios.AxiosInstance=Axios.create({
    basUrl:process.env.NODE_ENV==='production'?'http://49.232.77.197:8888':'',
    timeout:3000
})

HttpAxios.interceptors.request.use(function (config:axios.AxiosRequestConfig) {
    // Do something before request is sent
    return config;
  }, function (error:axios.AxiosError) {
    // Do something with request error
    return Promise.reject(error);
  });

// Add a response interceptor
HttpAxios.interceptors.response.use(function (response:axios.AxiosResponse) {
    // Do something with response data
    return response;
  }, function (error:axios.AxiosError) {
    // Do something with response error
    return Promise.reject(error);
  });

  export default{
      get<T extends object>(url:string,params?:T):axios.AxiosPromise{
            return HttpAxios.get(url,{
                params
            })
      },
      post<T extends object>(url:string,data?:T):axios.AxiosPromise{
            return HttpAxios.post(url,data)
      }
  }